#include "stdafx.h"
#include "SampleClass.h"
#include <boost/detail/interlocked.hpp>
#include <iostream>

Sample::SampleClass::SampleClass() : _refCount(0)
{
}

void Sample::SampleClass::AddRef ()
{
	std::cout << "+" ;
	BOOST_INTERLOCKED_INCREMENT (&_refCount);
}

void Sample::SampleClass::Release ()
{
	std::cout << "-" ;
	auto r = _refCount;
	if (BOOST_INTERLOCKED_DECREMENT (&_refCount) == 0)
		delete this;
}

void Sample::SampleClass::Print (const std::string& msg) const
{
	std::cout << msg << std::endl;
}